<?php

/* vim: set filetype=php: */

/**
 * @file
 * Install/uninstall visitors module.
 */

/**
 * Implements hook_install().
 */
function visitors_install() {
  variable_set('visitors_start_count_total_visitors', 0);
}

/**
 * Uninstall the module with database table and module settings.
 */
function visitors_uninstall() {
  drupal_uninstall_schema('visitors');

  variable_del('visitors_exclude_administer_users');
  variable_del('visitors_chart_height');
  variable_del('visitors_chart_width');
  variable_del('visitors_flush_log_timer');
  variable_del('visitors_last_registered_user');
  variable_del('visitors_lines_per_page');
  variable_del('visitors_published_nodes');
  variable_del('visitors_registered_user');
  variable_del('visitors_show_total_visitors');
  variable_del('visitors_show_unique_visitor');
  variable_del('visitors_since_date');
  variable_del('visitors_start_count_total_visitors');
  variable_del('visitors_user_ip');
}

/**
 * Implementats of hook_schema().
 */
function visitors_schema() {
  $schema['visitors'] = array(
    'fields' => array(
      'visitors_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'visitors_uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'visitors_ip' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'visitors_date_time' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'visitors_url' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
      'visitors_referer' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
      'visitors_path' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'visitors_title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'visitors_user_agent' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('visitors_id'),
  );

  return $schema;
}

